
<template>
    <van-nav-bar title="设置" left-text="返回" left-arrow @click-left="handleBack" />
    <div class="setting-box">
        <div class="agreement">
          <van-cell title="用户协议" is-link  @click="showAgreement=true"/>
          <van-cell title="隐私协议" is-link @click="showAgreement=true"/>
        </div>
        <div class="clear">
          <van-cell title="清除缓存" is-link @click='clearEvt'/>
        </div>
        <button @click="loginoutEvt">退出登录</button>
        <!-- <van-button color="#d4380d" plain :style="{width:'320px'}" @click="loginoutEvt">退出登录</van-button> -->
    </div>
    <van-popup v-model:show="showAgreement" position="bottom" >
        <div v-html="content"></div>
    </van-popup>
  </template>
  
  <script setup>
    import {getSuggestApi} from '../../apis/settingApi'
    import { commonDefinition } from '../../store'
    import {useRouter} from 'vue-router' 
    import { ref ,onMounted} from 'vue'
    const router = useRouter()
    //返回
    function handleBack(){
      router.back()
    }

  //点击弹出用户协议
  const showAgreement=ref(false)
  function agreementEvt(){
    showAgreement.value = false
  }
  const content = ref()
  onMounted(async function (){
    const result = await getSuggestApi()
    content.value=result.data
  })
  // 清除缓存并退出登录
  function clearEvt(){
    sessionStorage.clear()
    localStorage.clear()
    router.push('/login')
  }
  // 退出登录
  function loginoutEvt(){
    router.push('/login')
    sessionStorage.clear()
    localStorage.removeItem('auto-login')
  }
</script>
  
<style lang="less" scoped>
    @import '../../style/common.less';
    .setting-box{
      display: block;
      position: relative;
      height: 100%;
      margin-top: 20px;
        > .agreement{
        margin-bottom: 20px;
        background: white;
        }
        >.clear{
        margin-bottom: 20px;
        }
        >button{
          display: block;
          position: relative;
          border: solid 1px  #d4380d;
          background: white;
          font-size: .8rem;
          color: #d4380d;
          padding: 10px 140px;
          margin: auto;
          margin-top:10px ;
        }
    }
    >van-popup{
      padding: 0;
    }
</style>
  